((expr)=>{
    let isLoad=/(http[s]:\/\/)|(\/\/)/;
    function get_url(url){
        if(chrome.extension){
            return isLoad.test(url)?url:chrome.extension.getURL(url);
        }
        return url;
    }
    function load(url,callback,errback) {
        $.ajax({
            url: get_url(url),
            dataType: 'text',
            cache: false,
            async:!(callback===true),
            success(data) {
                if(typeof callback ==='function'){
                    callback(data);
                }else{
                    try{
                        window.eval(data);
                    }catch (e) {
                        console.log(e);
                    }
                }
            },
            error:errback
        });
    }
    function LoadToBlob(url,callback){
        let retUrl='';
        $.ajax({
            url: url,
            dataType: 'text',
            async:false,
            success(data) {
                let blob = new Blob([data]);
                let url = window.URL || window.webkitURL;
                retUrl = url.createObjectURL(blob);
            },
        });
        return retUrl;
    }
    expr.bLoad=load;
    expr.LoadToBlob=LoadToBlob;
    expr.getRealUrl=get_url;
})(window);

